from enum import Enum


class ServiceState(Enum):
    UP = 1
    DOWN = 2
    STARTING = 3
    STOPPING = 4
    UNKNOWN = 5


class ServiceDirection(Enum):
    UP = 1
    DOWN = 2
    NONE = 3


_available_service_tags = ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l']


def get_next_service_tag():
    assert(len(_available_service_tags) > 0)
    return _available_service_tags.pop(0)


class Service:
    def __init__(self):
        self.tag = get_next_service_tag()

    @property
    def name(self):
        return self._name

    @property
    def state(self):
        return self._state

    @property
    def branch(self):
        return self._branch

    def update_state(self):
        raise Exception('implement me')

    def update_branch(self):
        raise Exception('implement me')

    def update(self):
        self.update_branch()
        self.update_state()

    def start(self):
        raise Exception('implement me')

    def stop(self):
        raise Exception('implement me')

    def toggle(self):
        if self.state in [ServiceState.UP, ServiceState.UNKNOWN]:
            self.stop()
        elif self.state == ServiceState.DOWN:
            self.start()
